<?php
namespace App\Http\Controllers;

use App\Models\ActType;
use App\Models\GameType;
use Illuminate\Http\Request;


class GameTypeController extends CommonController
{
    /**
     *获取列表
     */
    public function getIndex()
    {

        $lists = GameType::paginate(10);

        return view('gametype.index')->with("lists", $lists)->with("actions", $this->actions);
    }

    /**
     * 执行一个搜索
     */
    public function search()
    {
    }

    /**
     * 获取创建页面
     */
    public function getCreate()
    {

        return view('gametype.create');
    }

    /**
     * 执行一个创建
     */
    public function postCreate(Request $request)
    {
        $data = $request->input();
        unset($data['formType'], $data['_token']);

        GameType::create($data);

        return AjaxCallbackMessage('游戏类型创建成功', true, url('gametype/index'));
    }

    /**
     * 获取编辑页面
     */
    public function getEdit(Request $request)
    {
        $data = $request->input();
        $list = GameType::where('id', $data['id'])->first();

        return view('gametype.edit')->with('list', $list);
    }

    /**
     * 执行一个编辑
     */
    public function postEdit(Request $request)
    {
        $data= $request->input();
        $id = $data['id'];
        unset($data['formType'], $data['_token']);

        GameType::where('id', $id)->update($data);

        return AjaxCallbackMessage('游戏类型编辑成功',true,url('gametype/index'));
    }

    /**
     * 执行一个删除
     */
    public function postDelete()
    {
    }
}